package edu.ustb.efws.base.controller.form;

import edu.ustb.efws.base.domain.User;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

/**
 * 新增用户
 *
 * @author TS Group
 */
@ApiModel(value = "新增用户")
public class UserSaveForm {
    @NotBlank
    @Size(max = 20)
    @ApiModelProperty(value = "用户名", required = true)
    private String username;
    @NotBlank
    @Size(max = 20)
    @ApiModelProperty(value = "密码", required = true)
    private String password;
    @NotNull
    @ApiModelProperty(value = "是否管理员", required = true)
    private Boolean admin;
    @Size(max = 20)
    @ApiModelProperty(value = "联系电话")
    private String tel;
    @NotNull
    @ApiModelProperty(value = "是否接收报警短信")
    private Boolean sms;
    @Size(max = 20)
    @ApiModelProperty(value = "姓名")
    private String name;
    @ApiModelProperty(value = "角色集合")
    private List<String> roles = new ArrayList<>();

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Boolean getAdmin() {
        return admin;
    }

    public void setAdmin(Boolean admin) {
        this.admin = admin;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Boolean getSms() {
        return sms;
    }

    public void setSms(Boolean sms) {
        this.sms = sms;
    }

    public List<String> getRoles() {
        return roles;
    }

    public void setRoles(List<String> roles) {
        this.roles = roles;
    }

    public User toDomain(){
        User t = new User();

        t.setUsername(username);
        t.setPassword(password);
        t.setAdmin(admin);
        t.setTel(tel);
        t.setName(name);
        t.setSms(sms);
        t.setRoles(roles);

        return t;
    }
}
